package com.qq.q22284625;
import java.io.File;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.java.JavaPlugin;



public class ChatHunger extends JavaPlugin implements Listener{
  public void onEnable(){
    getServer().getPluginManager().registerEvents(this, this);
	
    if(!getDataFolder().exists()) {
        getDataFolder().mkdir();
      }
    File file=new File(getDataFolder(),"config.yml");
    if (!(file.exists())) {saveDefaultConfig();}
    reloadConfig();
    
	getLogger().info("ChatHunger v4.0已加载.");
	getLogger().info("作者:Innovators BUG反馈QQ:22284625");
  }
  public void onDisable() {   
		getLogger().info("ChatHunger v4.0已卸载.");
		getLogger().info("作者:Innovators BUG反馈QQ:22284625");
  }
  
  @EventHandler
  public void onPlayerChat(AsyncPlayerChatEvent evt){
	   Player Player = evt.getPlayer();
	   int a = getConfig().getInt("ChatHunger.Default");
	   int b = getConfig().getInt("ChatHunger.Vip");
	   if (Player.hasPermission("ChatHunger.vip")){
		   Player.setFoodLevel(Player.getFoodLevel() - b);
	   }else if(Player.hasPermission("ChatHunger.op")){
		   
	   }else{
	   Player.setFoodLevel(Player.getFoodLevel() - a);
	   }
 }
}